package cl.sodimac.buc.helper; 

import com.bea.xml.XmlException;
import com.bea.xml.XmlObject;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Formnatt 
{ 
     private static SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
     
     public static java.sql.Date formatiFecha(String valor) throws ParseException {      
        Date parsed = format.parse(valor);
        return new java.sql.Date(parsed.getTime());
    }
    public static String xmlOracle2Java(oracle.xdb.XMLType xml) throws XmlException,SQLException {
        /*XmlObject obj=XmlObject.Factory.parse(xml.getDocument());
        return obj;*/
        return xml.getStringVal();
       
    }
    public static String clob2string(java.sql.Clob clob) throws XmlException,SQLException {
           String wholeClob = clob.getSubString(1, (int) clob.length());
             return wholeClob;
       
    }
    
  
    public static String date2string(java.util.Date fecha) {
		return format.format(fecha);
	}

    public static String parserMsgError(String msj) {
         return msj;
         /*
		try
        {
            String s=msj.split("<faultstring>")[1];
            
            s=s.split("</faultstring>")[0];
            
            if(s.length()>10)
             return s.substring(0,s.length());
            else
                return msj.substring(0,70);
        }
        catch (Exception e)
        {
            try
            {
                return msj.substring(0,70);
            }
             catch (Exception e1)
            {
                return msj;
            }
            
        }*/
	}

    
    
} 
